#pragma once                          
                                      
#include <fstream>                    
#include <iostream>                   
#include <cmath>                      
#include <opencv2/highgui.hpp>        
#include <opencv2/opencv.hpp>         
#include "../../include/common.hpp"   
#include "../../include/detection.hpp"


class Bridge_Detection
{

  public:
  int bridge_num = 1;
  int bridge_time = 0;
  bool bridge_enable = true;
  void reset()
  {
    bridge_num=1;
    bridge_enable = true;
  }
  
  void clear()
  {
    bridge_num=0;
  }
  
  bool Detection(vector<PredictResult> predict)
  {
    static int confidence =0; 
    bridge_time && bridge_time--;
    if(!bridge_enable)
    {
      return false;
    }
    for (uint16_t i = 0; i < predict.size(); i++)
        {
            if (predict[i].label == LABEL_BRIDGE)
            {
                confidence ++;
                if(confidence>=4)
                {
                  confidence = 0;
                  bridge_time = 40;
                  bridge_enable = false;
                  return true;
                }
            }
        }
    return false;
  }
};